package org.restql.db.resource;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.restql.db.Utility;

public class RequestResource {

	private String dbName;
	private String resourceName;
	private String user;
	private String password;
	private Map queryParameters;
	// 2009/11/15 restql-continue f.yang
	private String jdbcUrl;
	private String jdbcDriver;

	// 2009/11/15 restql-continue f.yang
	@SuppressWarnings("unchecked")
	public RequestResource(String dbName, String resourceName, String user,
			String password, Map queryParameters, String jdbcUrl, String jdbcDriver) {
		this.dbName = dbName;
		this.resourceName = Utility.nameJs2Sql(resourceName);
		this.user = user;
		this.password = password;
		this.queryParameters = queryParameters;
		// 2009/11/15 restql-continue f.yang
		this.jdbcUrl = jdbcUrl;
		this.jdbcDriver = jdbcDriver;
		
		Map sqlQueryParameters = new HashMap();
		for (String key: (Set<String>) (this.queryParameters.keySet())) {
			sqlQueryParameters.put(Utility.nameJs2Sql(key),this.queryParameters.get(key));
		}
		this.queryParameters = sqlQueryParameters; 
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Map getQueryParameters() {
		return queryParameters;
	}

	public void setQueryParameters(Map queryParameters) {
		this.queryParameters = queryParameters;
	}

	public String getDbName() {
		return dbName;
	}

	public void getDbName(String dbName) {
		this.dbName = dbName;
	}

	public String getResourceName() {
		return resourceName;
	}

	public void setResourceName(String resourceName) {
		this.resourceName = resourceName;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	// 2009/11/15	restql-continue	f.yang
	public String getJdbcUrl() {
		//"jdbc:mysql://localhost:3306/" + getDbName()
		return this.jdbcUrl;
	}
	
	public String getConnectString() {
		return jdbcUrl + "||" + getUser() + "||" + getPassword();
	}

	public String getJdbcDriver() {
        //"com.mysql.jdbc.Driver"
		return jdbcDriver;
	}
	
}
